const render = require('koa-art-template');
const path = require("path");
const koaBody =  require("koa-body");
const requireDir = require("require-directory");
const Router = require("koa-router")
const static = require("koa-static")
function initProject(app){
    
    app.use(koaBody({
        multipart: true,
        formidable: {
            maxFileSize: 200 * 1024 * 1024,
            keepExtensions: true
        }
    }))
    app.use(static(path.join(process.cwd(),"static")))
  
    requireDir(module,"../routers",{visit:loadRoutes})
    render(app, {
        root: path.join(process.cwd(), 'pages'),
        extname: '.html',
        debug: process.env.NODE_ENV !== 'production'
    });
    function loadRoutes(obj){
        // console.log(obj instanceof Router);
        if(obj instanceof Router){
            app.use(obj.routes());
        }
    }
}
module.exports = initProject;